package org.smoozik.app.ihm;

import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;

import org.smoozik.services.musictheory.Interval;
import org.smoozik.services.util.ImageLoader;

public class Constants {

	/**
	 * UI Images
	 */

	public final static BufferedImage sharpImg = getImage("diese.gif");
	public final static BufferedImage flatImg = getImage("bemol.gif");
	public final static BufferedImage noteImg = getImage("note.gif");
	public final static BufferedImage blancheImg = getImage("blanche.gif");
	public final static BufferedImage faImg = getImage("fa.gif");
	public final static BufferedImage solImg = getImage("sol.gif");
	// public final static BufferedImage backgroundImg = getImage("fond.jpg");

	/**
	 * Music theory constants
	 */

	// Note
	public final static int DO = 0;
	public final static int RE = 1;
	public final static int MI = 2;
	public final static int FA = 3;
	public final static int SOL = 4;
	public final static int LA = 5;
	public final static int SI = 6;

	public final static String DO_LABEL = "C";
	public final static String RE_LABEL = "D";
	public final static String MI_LABEL = "E";
	public final static String FA_LABEL = "F";
	public final static String SOL_LABEL = "G";
	public final static String LA_LABEL = "A";
	public final static String SI_LABEL = "B";

	public static final int[] indexValues = { 0, 2, 4, 5, 7, 9, 11 };
	public static final int[] NOTES = { DO, RE, MI, FA, SOL, LA, SI };
	public static final String[] NOTE_LABELS = { DO_LABEL, RE_LABEL, MI_LABEL,
			FA_LABEL, SOL_LABEL, LA_LABEL, SI_LABEL };

	// Interval
	public final static Interval UNISSON = new Interval(0, 0);
	public final static Interval SECONDE_DIM = new Interval(1, 1);
	public final static Interval SECONDE = new Interval(1, 2);
	public final static Interval TIERCE_MIN = new Interval(2, 3);
	public final static Interval TIERCE = new Interval(2, 4);
	public final static Interval QUARTE = new Interval(3, 5);
	public final static Interval TRITON = new Interval(4, 6);
	public final static Interval QUINTE = new Interval(4, 7);
	public final static Interval SIXTE_MIN = new Interval(5, 8);
	public final static Interval SIXTE = new Interval(5, 9);
	public final static Interval SEPTIEME_MIN = new Interval(6, 10);
	public final static Interval SEPTIEME = new Interval(6, 11);
	public final static Interval OCTAVE = new Interval(7, 12);
	public final static Interval OCTAVE_INF = new Interval(-7, -12);

	public final static Interval DEMITON = new Interval(1, 1);
	public final static Interval TON = new Interval(1, 2);
	public final static Interval TONETDEMI = new Interval(1, 3);

	public static final Interval[] INTERVALS = { UNISSON, SECONDE_DIM, SECONDE,
			TIERCE_MIN, TIERCE, QUARTE, TRITON, QUINTE, SIXTE_MIN, SIXTE,
			SEPTIEME_MIN, SEPTIEME, OCTAVE };
	public static final String[] INTERVAL_NAMES = { "UNISSON", "SECONDE_DIM",
			"SECONDE", "TIERCE_MIN", "TIERCE", "QUARTE", "TRITON", "QUINTE",
			"SIXTE_MIN", "SIXTE", "SEPTIEME_MIN", "SEPTIEME", "OCTAVE" };

	// Chord
	public final static int MAJOR = 0;
	public final static int MINOR = 1;

	// 3 notes chords
	public static final Interval[] MAJEUR = { TIERCE, TIERCE_MIN };
	public static final Interval[] MINEUR = { TIERCE_MIN, TIERCE };
	public static final Interval[] DIMINUE = { TIERCE_MIN, TIERCE_MIN };
	public static final Interval[] AUGMENTE = { TIERCE, TIERCE };

	// 4 notes chords
	public static final Interval[] MAJ7 = { TIERCE, TIERCE_MIN, TIERCE };
	public static final Interval[] M7 = { TIERCE, TIERCE_MIN, TIERCE_MIN };
	public static final Interval[] MIN7 = { TIERCE_MIN, TIERCE, TIERCE_MIN };
	public static final Interval[] DIM7 = { TIERCE_MIN, TIERCE_MIN, TIERCE };

	public static final Interval[][] CHORDS = { MAJEUR, MINEUR, DIMINUE,
			AUGMENTE, MAJ7, M7, MIN7, DIM7 };
	public static final String[] CHORD_NAMES = { "MAJEUR", "MINEUR", "DIMINUE",
			"AUGMENTE", "MAJ7", "M7", "MIN7", "DIM7" };

	// Scales
	public static final Interval[] MODE1_SCALE = { TON, TON, DEMITON, TON, TON,
			TON, DEMITON };
	public static final Interval[] MODE2_SCALE = { TON, DEMITON, TON, TON, TON,
			DEMITON, TON };
	public static final Interval[] MODE3_SCALE = { DEMITON, TON, TON, TON,
		DEMITON, TON, TON };
	public static final Interval[] MODE3_SCALE_MAJ = { DEMITON, TONETDEMI, DEMITON, TON,
		DEMITON, TON, TON };
	public static final Interval[] MODE4_SCALE = { TON, TON, TON, DEMITON, TON,
			TON, DEMITON };
	public static final Interval[] MODE5_SCALE = { TON, TON, DEMITON, TON, TON,
			DEMITON, TON };
	public static final Interval[] MODE6_SCALE = { TON, DEMITON, TON, TON,
			DEMITON, TON, TON };
	public static final Interval[] MODE7_SCALE = { DEMITON, TON, TON, DEMITON,
			TON, TON, TON };
	public static final Interval[] MINOR_MEL_SCALE = { TON, DEMITON, TON, TON,
			DEMITON, TON, TIERCE_MIN };
	public static final Interval[] PENTA_MIN_SCALE = { TONETDEMI, TON, TON,
			TIERCE_MIN, TON };

	public static final Interval[][] SCALES = { MODE1_SCALE, MODE2_SCALE,
			MODE3_SCALE, MODE4_SCALE, MODE5_SCALE, MODE6_SCALE, MODE7_SCALE,
			MINOR_MEL_SCALE, PENTA_MIN_SCALE };
	public static final String[] SCALE_NAMES = { "MODE1_SCALE", "MODE2_SCALE",
			"MODE3_SCALE", "MODE4_SCALE", "MODE5_SCALE", "MODE6_SCALE",
			"MODE7_SCALE", "MINOR_MEL_SCALE", "PENTA_MIN_SCALE" };

	// Key

	public final static int G_KEY = 0;
	public final static int F_KEY = 1;
	public static final String[] keyLabels = { SOL_LABEL, FA_LABEL };
	public static final Image[] keyImages = { solImg, faImg };

	public final static int G_HEIGHT = 9;
	public final static int F_HEIGHT = 4;

	// Harmonies

	public final static char SHARP = '#';
	public final static char FLAT = 'b';

	// sharp harmonies
	// fa do sol re la li si
	public final static int[] SHARP_HARMONY_NOTES = { FA, DO, SOL, RE, LA, MI,
			SI };
	public final static String[] SHARP_HARMONY_NAMES = { "G", "D", "A", "E",
			"B", "F#", "C#" };

	// flat harmonies
	// si mi la re sol do fa
	public final static int[] FLAT_HARMONY_NOTES = { SI, MI, LA, RE, SOL, DO,
			FA };
	public final static String[] FLAT_HARMONY_NAMES = { "F", "Bb", "Eb", "Ab",
			"Db", "Gb", "Cb" };

	/**
	 * Main frame constants
	 */

	public static final String FRAME_TITLE = "Music theory trainer";
	// Menu and menu items
	public static final String GAME_LABEL = "Game";
	public static final String END_LABEL = "Show Score";
	public static final String RESET_LABEL = "Reset";
	public static final String SETTINGS_LABEL = "Settings";

	// Settings Frame labels
	public static final String MODE_LABEL = "Mode";
	public static final String VOLUME_LABEL = "Volume";
	public static final String OK_LABEL = "Ok";
	public static final String CANCEL_LABEL = "Cancel";

	/**
	 * Line trainer mode constants
	 */
	// title
	public static final String LINE_TRAINER_LABEL = "Line Trainer";
	public static final String LINE_TRAINER_ID = "LineTrainer";

	// Labels
	public static final String NOTE_LABEL = "Note";
	public static final String CHORD_LABEL = "Chord";
	public static final String INTERVAL_LABEL = "Interval";
	public static final String MINOR_LABEL = "Minor";
	public static final String MAJOR_LABEL = "Major";
	public static final String SHARP_LABEL = "#";
	public static final String BEMOL_LABEL = "b";
	public static final String GO_LABEL = "Go";
	public static final String START_LABEL = "Start";
	public static final String RECORD_LABEL = "Record";
	public static final String STOP_LABEL = "Stop";
	public static final String REPLAY_LABEL = "Replay";
	public static final String PLAY_LABEL = "Play";
	public static final String PAUSE_LABEL = "Pause";
	public static final String OPEN_LABEL = "Open";
	public static final String RELOAD_LABEL = "Relaod";
	public static final String GEN_LABEL = "Gen";
	public static final String SAVE_LABEL = "Save";
	public static final String REC_LABEL = "Rec";
	public static final String DONE_LABEL = "Done";
	public static final String SELECT_LABEL = "Select";
	public static final String PLUS_LABEL = "+";
	public static final String MINUS_LABEL = "-";

	public static int noteKeys[] = { KeyEvent.VK_C, KeyEvent.VK_D,
			KeyEvent.VK_E, KeyEvent.VK_F, KeyEvent.VK_G, KeyEvent.VK_A,
			KeyEvent.VK_B };

	// Game constants
	public static final int MAX_COUNT = 20;

	public final static int LEFT_TO_RIGHT = 1;
	public final static int RIGHT_TO_LEFT = 0;

	// Settings Frame labels
	public static final String KEY_LABEL = "Key";
	public static final String NUMBER_LABEL = "Number of notes";
	public static final String SPEED_LABEL = "Speed";
	public static final String PARTMIDDLE_LABEL = "Middle of the partition";
	public static final String SHARPBEMOL_LABEL = "Allow sharp and bemol";
	public static final String RENVERSEMENT_LABEL = "Renversement";
	public static final String PIANO_LABEL = "Piano";
	public static final String PARTITION_LABEL = "Partition";
	public static final String FIGURE_LABEL = "Figure";
	public static final String FIGURE_NOTE = "Note";
	public static final String FIGURE_CHORD = "Chord";
	public static final String FIGURE_INTERVAL = "Interval";
	public static final String SENSE_LABEL = "Orientation";

	/**
	 * Generator mode constants
	 */
	// title
	public static final String GENERATOR_LABEL = "Generator";
	public static final String GENERATOR_ID = "Generator";
	public final static int GEN_SPEED = 500;
	public final static int GEN_NBTIMES = 4;
	public final static int GEN_MEASURES = 24;

	/**
	 * RythmTrainer mode constants
	 */
	// title
	public static final String RYTHMTRAINER_LABEL = "Rythm Trainer";
	public static final String RYTHMTRAINER_ID = "Rythm Trainer";

	/**
	 * Partition constants
	 */

	public final static int DEFAULT_INTERVAL = 8;

	public static final int DEFAULT_HEIGHT = 100;
	public static final int DEFAULT_LEFT_MARGIN = 10;
	public static final int DEFAULT_RIGHT_MARGIN = 1000;
	public static final int DEFAULT_LENGTH = 1200;
	public static final int SONG_PANEL_WIDTH = 1400;
	// Frame constants

	/**
	 * Recorder mode constants
	 */

	// Timeline modes
	public static final int TL_MODE_REC = 1;
	public static final int TL_MODE_LEC = 2;

	/**
	 * Default settings
	 */

	public final static int DEFAULT_TL_MODE = TL_MODE_REC;
	public final static int DEFAULT_KEY = G_KEY;
	public final static int DEFAULT_NBNOTES = 29;
	public final static String DEFAULT_FIGURE = FIGURE_NOTE;
	public final static String DEFAULT_MODE = RYTHMTRAINER_ID;
	public final static int DEFAULT_SPEED = 1;
	public final static int DEFAULT_MIDPART = -5;
	public final static int DEFAULT_RENVERSEMENT = 1;
	public final static int DEFAULT_ALLOWSHARP = 0;
	public final static int DEFAULT_SENSE = LEFT_TO_RIGHT;

	public final static int TIMER_SENSE[] = { -1, 1 };
	public final static int MARGIN[] = { DEFAULT_RIGHT_MARGIN,
			DEFAULT_LEFT_MARGIN };
	public static final int DEFAULT_MARGIN = MARGIN[DEFAULT_SENSE];
	public static final int DEFAULT_TIMER_SENSE = TIMER_SENSE[DEFAULT_SENSE];

	public static BufferedImage getImage(String name) {

		ImageLoader loader = new ImageLoader();
		
		return loader.loadImage(name);
		

	}
}
